home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / MachineExceptions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  4.1 KB  |  179 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        MachineExceptions.h
  3.  
  4.      Contains:    Processor Exception Handling Interfaces .
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __MACHINEEXCEPTIONS__
  21. #define __MACHINEEXCEPTIONS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32.  
  33. #if PRAGMA_ALIGN_SUPPORTED
  34. #pragma options align=power
  35. #endif
  36.  
  37. #if PRAGMA_IMPORT_SUPPORTED
  38. #pragma import on
  39. #endif
  40.  
  41. typedef KernelID AreaID;
  42.  
  43. /* Machine Dependent types for PowerPC: */
  44. struct MachineInformationPowerPC {
  45.     UnsignedWide                    CTR;
  46.     UnsignedWide                    LR;
  47.     UnsignedWide                    PC;
  48.     unsigned long                    CR;
  49.     unsigned long                    XER;
  50.     unsigned long                    MSR;
  51. };
  52. typedef struct MachineInformationPowerPC MachineInformationPowerPC;
  53.  
  54. struct RegisterInformationPowerPC {
  55.     UnsignedWide                    R0;
  56.     UnsignedWide                    R1;
  57.     UnsignedWide                    R2;
  58.     UnsignedWide                    R3;
  59.     UnsignedWide                    R4;
  60.     UnsignedWide                    R5;
  61.     UnsignedWide                    R6;
  62.     UnsignedWide                    R7;
  63.     UnsignedWide                    R8;
  64.     UnsignedWide                    R9;
  65.     UnsignedWide                    R10;
  66.     UnsignedWide                    R11;
  67.     UnsignedWide                    R12;
  68.     UnsignedWide                    R13;
  69.     UnsignedWide                    R14;
  70.     UnsignedWide                    R15;
  71.     UnsignedWide                    R16;
  72.     UnsignedWide                    R17;
  73.     UnsignedWide                    R18;
  74.     UnsignedWide                    R19;
  75.     UnsignedWide                    R20;
  76.     UnsignedWide                    R21;
  77.     UnsignedWide                    R22;
  78.     UnsignedWide                    R23;
  79.     UnsignedWide                    R24;
  80.     UnsignedWide                    R25;
  81.     UnsignedWide                    R26;
  82.     UnsignedWide                    R27;
  83.     UnsignedWide                    R28;
  84.     UnsignedWide                    R29;
  85.     UnsignedWide                    R30;
  86.     UnsignedWide                    R31;
  87. };
  88. typedef struct RegisterInformationPowerPC RegisterInformationPowerPC;
  89.  
  90. struct FPUInformationPowerPC {
  91.     UnsignedWide                    Registers[32];
  92.     unsigned long                    FPSCR;
  93.     unsigned long                    Reserved;
  94. };
  95. typedef struct FPUInformationPowerPC FPUInformationPowerPC;
  96.  
  97.  
  98. enum {
  99.     writeReference                = 0,
  100.     readReference                = 1,
  101.     fetchReference                = 2
  102. };
  103.  
  104. typedef unsigned long MemoryReferenceKind;
  105.  
  106. struct MemoryExceptionInformation {
  107.     AreaID                            theArea;
  108.     LogicalAddress                    theAddress;
  109.     OSStatus                        theError;
  110.     MemoryReferenceKind                theReference;
  111. };
  112. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  113.  
  114.  
  115. enum {
  116.     unknownException            = 0,
  117.     illegalInstructionException    = 1,
  118.     trapException                = 2,
  119.     accessException                = 3,
  120.     unmappedMemoryException        = 4,
  121.     excludedMemoryException        = 5,
  122.     readOnlyMemoryException        = 6,
  123.     unresolvablePageFaultException = 7,
  124.     privilegeViolationException    = 8,
  125.     traceException                = 9,
  126.     instructionBreakpointException = 10,
  127.     dataBreakpointException        = 11,
  128.     integerException            = 12,
  129.     floatingPointException        = 13,
  130.     stackOverflowException        = 14,
  131.     terminationException        = 15
  132. };
  133.  
  134. typedef unsigned long ExceptionKind;
  135.  
  136. union ExceptionInfo {
  137.     MemoryExceptionInformation        *memoryInfo;
  138. };
  139. typedef union ExceptionInfo ExceptionInfo;
  140.  
  141. struct ExceptionInformationPowerPC {
  142.     ExceptionKind                    theKind;
  143.     MachineInformationPowerPC        *machineState;
  144.     RegisterInformationPowerPC        *registerImage;
  145.     FPUInformationPowerPC            *FPUImage;
  146.     ExceptionInfo                    info;
  147. };
  148. typedef struct ExceptionInformationPowerPC ExceptionInformationPowerPC;
  149.  
  150. #if GENERATINGPOWERPC
  151. typedef ExceptionInformationPowerPC ExceptionInformation;
  152.  
  153. typedef MachineInformationPowerPC MachineInformation;
  154.  
  155. typedef RegisterInformationPowerPC RegisterInformation;
  156.  
  157. typedef FPUInformationPowerPC FPUInformation;
  158.  
  159. #endif
  160. /* Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  161.             It must be a native function pointer with NO routine descriptor. */
  162. typedef OSStatus (*ExceptionHandler)(ExceptionInformationPowerPC *theException);
  163. /* Routine for installing per-process exception handlers */
  164. extern pascal ExceptionHandler InstallExceptionHandler(ExceptionHandler theHandler);
  165.  
  166. #if PRAGMA_IMPORT_SUPPORTED
  167. #pragma import off
  168. #endif
  169.  
  170. #if PRAGMA_ALIGN_SUPPORTED
  171. #pragma options align=reset
  172. #endif
  173.  
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177.  
  178. #endif /* __MACHINEEXCEPTIONS__ */
  179.